<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <body>
        <ui:composition template="../templates/default3.xhtml">
            <ui:define name="content">
                <h:form id="manageSuppliers" binding="#{supplierManagerBean.loadManageSuppliers}">
                    <p:panel header="Suppliers" id="suppliersPanel">
                        <p:messages />

                        <p:dataTable id="suppliers" var="supplier" value="#{supplierManagerBean.suppliers}" selectionMode="single" 
                                     selection="#{supplierManagerBean.selectedSupplier}" update="suppliersPanel"  paginator="true" rows="10"  
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" >
                            <p:column filterBy="#{supplier.supplierId}" headerText="Supplier Id" filterMatchMode="contains">  
                                <h:outputText value="#{supplier.supplierId}" />  
                            </p:column> 
                            <p:column filterBy="#{supplier.name}" headerText="Name" filterMatchMode="contains">  
                                <h:outputText value="#{supplier.name}" />  
                            </p:column> 
                            <p:column filterBy="#{supplier.company}" headerText="Company" filterMatchMode="contains">  
                                <h:outputText value="#{supplier.company}" />  
                            </p:column>
                            <p:column filterBy="#{supplier.contact}" headerText="Contact" filterMatchMode="contains">  
                                <h:outputText value="#{supplier.contact}" />  
                            </p:column> 
                            <p:column filterBy="#{supplier.email}" headerText="Email" filterMatchMode="contains">  
                                <h:outputText value="#{supplier.email}" />  
                            </p:column> 
                        </p:dataTable>
                        <table class="table-submit">
                            <tr>
                                <td align="center">
                                    <p:commandButton id="btnViewSupplier" value="View Supplier" 
                                                     title="View selected supplier." ajax="true"
                                                     update="suppliersPanel"
                                                     actionListener="#{supplierManagerBean.viewSupplier}" />
                                  
                                    <p:commandButton id="btnUpdateSupplier" value="Update Supplier" 
                                                     title="Update selected supplier." ajax="true"
                                                     update="suppliersPanel"
                                                     actionListener="#{supplierManagerBean.updateSupplier}" />
                                   
                                    <p:commandButton id="btnRemoveSupplier" value="Remove Supplier" 
                                                     onclick="confirmation.show()" type="button"
                                                     title="Remove the selected product." />
                                </td>
                            </tr>
                        </table>
                    </p:panel>
                    <p:confirmDialog  width="400" message="" header="Removing a Supplier" severity="alert" widgetVar="confirmation">
                        <f:facet name="message">
                            <h:outputText value="You are going to remove a supplier."/><br/>
                            <h:outputText value="Are you sure you want to continue?"/>
                        </f:facet>    
                        <p:commandButton value="Yes" update="suppliersPanel" onclick="confirmation.hide()"
                                         actionListener="#{supplierManagerBean.removeSupplier}"/>
                        <p:commandButton value="No" update="suppliersPanel" onclick="confirmation.hide()" type="button" />
                    </p:confirmDialog>
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
